define(function(require,exports,module){
    var Base={
		mBaserSvrUrl:window.BaseServerUrl,
		localStorage:window.localStorage
	};
	
	function JlnRequest(){
		this.params={}
	}
	module.exports=ApprovalProxy;
function ApprovalProxy(){
	function approvalSubmit(request, success, ignoreError) {
	    var url = Base.mBaserSvrUrl+'/approval';
        if (request.svr == null) request.svr = undefined;
	    if (request.token == null) request.token = undefined;
	    var content = JSON.stringify(request);
       
	    url = url + '?f=t&data=' + encodeURIComponent(content);
	    url = url + '&CallBack=?';
        $.getJSON(url,success);

	}

	function approvalRq(union,userToken,approvalId,result,opinion,next,remark,success,ignoreError){
        var request=new JlnRequest();
        request.func='approval';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['aid']=approvalId;
		request.params['r']=result;
		request.params['o']=opinion;
		request.params['n']=next;
		request.params['r0']=remark;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.approvalRequest=function(userToken,approvalId,result,opinion,next,remark,success,ignoreError){
       var request= approvalRq(true,userToken,approvalId,result,opinion,next,remark,success,ignoreError);
       return request;
    }
	this.approval=function(userToken,approvalId,result,opinion,next,remark,success,ignoreError){
       var request= approvalRq(false,userToken,approvalId,result,opinion,next,remark,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getMyWaitApprovalsRq(union,userToken,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='getMyWaitApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['t']=type;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['r']=result;
		request.params['d']=description;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getMyWaitApprovalsRequest=function(userToken,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError){
       var request= getMyWaitApprovalsRq(true,userToken,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError);
       return request;
    }
	this.getMyWaitApprovals=function(userToken,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError){
       var request= getMyWaitApprovalsRq(false,userToken,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getMyWaitApprovalsCountRq(union,userToken,type,success,ignoreError){
        var request=new JlnRequest();
        request.func='getMyWaitApprovalsCount';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['t']=type;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getMyWaitApprovalsCountRequest=function(userToken,type,success,ignoreError){
       var request= getMyWaitApprovalsCountRq(true,userToken,type,success,ignoreError);
       return request;
    }
	this.getMyWaitApprovalsCount=function(userToken,type,success,ignoreError){
       var request= getMyWaitApprovalsCountRq(false,userToken,type,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getMyHistoryApprovalsRq(union,userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='getMyHistoryApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['t']=type;
		request.params['r']=result;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getMyHistoryApprovalsRequest=function(userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getMyHistoryApprovalsRq(true,userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError);
       return request;
    }
	this.getMyHistoryApprovals=function(userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getMyHistoryApprovalsRq(false,userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getWaitApprovalsRq(union,userToken,type,beginTime,endTime,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='getWaitApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['t']=type;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getWaitApprovalsRequest=function(userToken,type,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getWaitApprovalsRq(true,userToken,type,beginTime,endTime,page,countPerPage,success,ignoreError);
       return request;
    }
	this.getWaitApprovals=function(userToken,type,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getWaitApprovalsRq(false,userToken,type,beginTime,endTime,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getHistoryApprovalsRq(union,userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='getHistoryApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['t']=type;
		request.params['r']=result;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getHistoryApprovalsRequest=function(userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getHistoryApprovalsRq(true,userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError);
       return request;
    }
	this.getHistoryApprovals=function(userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getHistoryApprovalsRq(false,userToken,type,result,beginTime,endTime,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function claimApprovalRq(union,userToken,approvalId,success,ignoreError){
        var request=new JlnRequest();
        request.func='claimApproval';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['aid']=approvalId;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.claimApprovalRequest=function(userToken,approvalId,success,ignoreError){
       var request= claimApprovalRq(true,userToken,approvalId,success,ignoreError);
       return request;
    }
	this.claimApproval=function(userToken,approvalId,success,ignoreError){
       var request= claimApprovalRq(false,userToken,approvalId,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function cancelClaimApprovalRq(union,userToken,approvalId,success,ignoreError){
        var request=new JlnRequest();
        request.func='cancelClaimApproval';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['aid']=approvalId;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.cancelClaimApprovalRequest=function(userToken,approvalId,success,ignoreError){
       var request= cancelClaimApprovalRq(true,userToken,approvalId,success,ignoreError);
       return request;
    }
	this.cancelClaimApproval=function(userToken,approvalId,success,ignoreError){
       var request= cancelClaimApprovalRq(false,userToken,approvalId,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function assignApprovalRq(union,userToken,approvalId,userId,success,ignoreError){
        var request=new JlnRequest();
        request.func='assignApproval';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['aid']=approvalId;
		request.params['uid']=userId;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.assignApprovalRequest=function(userToken,approvalId,userId,success,ignoreError){
       var request= assignApprovalRq(true,userToken,approvalId,userId,success,ignoreError);
       return request;
    }
	this.assignApproval=function(userToken,approvalId,userId,success,ignoreError){
       var request= assignApprovalRq(false,userToken,approvalId,userId,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getMyRequestRq(union,ownerType,ownerId,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='getMyRequest';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['ot']=ownerType;
		request.params['oid']=ownerId;
		request.params['t']=type;
		request.params['r']=result;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getMyRequestRequest=function(ownerType,ownerId,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getMyRequestRq(true,ownerType,ownerId,type,result,beginTime,endTime,page,countPerPage,success,ignoreError);
       return request;
    }
	this.getMyRequest=function(ownerType,ownerId,type,result,beginTime,endTime,page,countPerPage,success,ignoreError){
       var request= getMyRequestRq(false,ownerType,ownerId,type,result,beginTime,endTime,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function queryWaitApprovalsRq(union,userToken,claimStatus,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='queryWaitApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['cs']=claimStatus;
		request.params['t']=type;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['r']=result;
		request.params['d']=description;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.queryWaitApprovalsRequest=function(userToken,claimStatus,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError){
       var request= queryWaitApprovalsRq(true,userToken,claimStatus,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError);
       return request;
    }
	this.queryWaitApprovals=function(userToken,claimStatus,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError){
       var request= queryWaitApprovalsRq(false,userToken,claimStatus,type,beginTime,endTime,result,description,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getMyWaitOrderApprovalsRq(union,userToken,beginTime,endTime,result,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='getMyWaitOrderApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['r']=result;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getMyWaitOrderApprovalsRequest=function(userToken,beginTime,endTime,result,page,countPerPage,success,ignoreError){
       var request= getMyWaitOrderApprovalsRq(true,userToken,beginTime,endTime,result,page,countPerPage,success,ignoreError);
       return request;
    }
	this.getMyWaitOrderApprovals=function(userToken,beginTime,endTime,result,page,countPerPage,success,ignoreError){
       var request= getMyWaitOrderApprovalsRq(false,userToken,beginTime,endTime,result,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function queryWaitOrderApprovalsRq(union,userToken,claimStatus,beginTime,endTime,result,page,countPerPage,success,ignoreError){
        var request=new JlnRequest();
        request.func='queryWaitOrderApprovals';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['cs']=claimStatus;
		request.params['bt']=beginTime;
		request.params['et']=endTime;
		request.params['r']=result;
		request.params['p']=page;
		request.params['cpp']=countPerPage;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.queryWaitOrderApprovalsRequest=function(userToken,claimStatus,beginTime,endTime,result,page,countPerPage,success,ignoreError){
       var request= queryWaitOrderApprovalsRq(true,userToken,claimStatus,beginTime,endTime,result,page,countPerPage,success,ignoreError);
       return request;
    }
	this.queryWaitOrderApprovals=function(userToken,claimStatus,beginTime,endTime,result,page,countPerPage,success,ignoreError){
       var request= queryWaitOrderApprovalsRq(false,userToken,claimStatus,beginTime,endTime,result,page,countPerPage,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }

	function getMyWaitOrderApprovalsCountRq(union,userToken,success,ignoreError){
        var request=new JlnRequest();
        request.func='getMyWaitOrderApprovalsCount';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;

		if (union == true) {
	        request.svr = 'approval';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.getMyWaitOrderApprovalsCountRequest=function(userToken,success,ignoreError){
       var request= getMyWaitOrderApprovalsCountRq(true,userToken,success,ignoreError);
       return request;
    }
	this.getMyWaitOrderApprovalsCount=function(userToken,success,ignoreError){
       var request= getMyWaitOrderApprovalsCountRq(false,userToken,success,ignoreError);
       approvalSubmit(request, success, ignoreError);

    }
}

});
